import * as multer from 'multer';
import * as fs from 'fs';
export const storage = multer.diskStorage({
  destination: function (req, file, callback) {
    try {
      fs.mkdirSync('uploads');
    } catch (e) {}
    callback(null, 'uploads');
  },
  filename: function (req, file, callback) {
    const decodeName = Buffer.from(file.originalname, 'latin1').toString(
      'utf8',
    );
    const uniqueSuffix =
      Date.now() + '-' + Math.round(Math.random() * 1e9) + '-' + decodeName;
    callback(null, uniqueSuffix);
  },
});
